Formatting XML Traffic Reports with XSL style sheets
XSL is built around the style sheet mechanism. Style sheets are generally used to apply styles, or formatting information, consistently throughout a document. The XSL transformation language (xsl namespace) is a description of how a processor can transform an XML document from one structure to another. The transformation process in a general sense takes one document tree and transforms it into another document tree.
Here is an example of XML Traffic Report produced by TrafMeter:
<?xml version="1.0"?> <TrafficReport> <Filter Id="1"> <Name>ICMP</Name> <Sent>3267224</Sent> <Recv>3267224</Recv> </Filter> <Filter Id="2"> <Name>TCP</Name> <Sent>499413566</Sent> <Recv>12098967</Recv> </Filter> <LastModified>November, 26 2002 11:19:14</LastModified> </TrafficReport> |
When you open this document in Microsoft Internet Explorer, it will look as follows:
This is not very clear. However, if a prolog of XML Traffic Report contains a reference to the external XSL style sheets describing a formatting of this report:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="traffic.xsl"?> <TrafficReport> |
it will look with another view in Microsoft Internet Explorer:
The source code of traffic.xsl can be found here. You can create own XSL style sheets to customize your XML Traffic Reports as well. The other example of using XSL style sheets is follows:
This XSL (traffic2.xsl) shows the traffic counters in megabytes. The source code of traffic2.xsl can be found here.